#!/usr/bin/perl -w
# GetFileSize.pl
#
# AUTHOR: James C. Estill
# CONTACT: jestill_at_uga.edu
# STARTED: 1/20/2005
# UPDATED: 1/20/2005
#
# DESCRIPTION:
# Subfunction to get file size of a file in a usable form
# This shows the file in GB,MB, or KB with two numbers
# past the decimal point.




sub GetFileSize 
{
  my $SearchFile = $_[0];
  my $DbByteFileSize = (stat("$SearchFile"))[7];
  if ($DbByteFileSize > 1000000000)                     # For files more than a gigabyte show in GB
    {
      $DbFileSize = sprintf("%.2f", ($DbByteFileSize/1000000000));
      $SizeSuffix = "GB";
    }
  elsif ($DbByteFileSize > 1000000)
    {
      $DbFileSize = sprintf("%.2f", ($DbByteFileSize/1000000));
      $SizeSuffix = "MB";
    }
  else
    {
      $DbFileSize = sprintf("%.2f", ($DbByteFileSize/1000));
      $SizeSuffix = "KB";
    }
  my $FileSizeAnswer = "$DbFileSize $SizeSuffix";
  return $FileSizeAnswer;

}

